//
//  SGFDBDetailViewController.m
//  Estate
//
//  Created by wangdongdong on 16/7/22.
//  Copyright © 2016年 ttsx. All rights reserved.
//


#import "SGFDBDetailViewController.h"
#import "SegmentViewController.h"
#import "JLLiuZhuanViewController.h"
#import "ProcessRecordModel.h"
#import "BasicInformationViewController.h"
#import "FDAlertView.h"
#import "AlertVIew.h"
#import "GLDBViewController_Detail_B.h"

@interface SGFDBDetailViewController ()
{
    FDAlertView *alert;
    FMDatabase *_db;
    //判断是否合格
    int _qualified;
}

//设置按钮标题
@property (retain, nonatomic) NSMutableArray *titArr;
@property (nonatomic,strong) NSMutableArray *processRecoedArray;
// 最新的流程记录
@property (nonatomic, strong) ProcessRecordModel *currentRecordModel;

// 最早的流程记录
@property (nonatomic, strong) ProcessRecordModel *firstModel;

@property (copy, nonatomic) NSString *content;

// 流程记录ID
@property (strong, nonatomic) NSString *flowRecordID;
// 附件信息
@property (strong, nonatomic) NSString *fileinfos;

@end

@implementation SGFDBDetailViewController

- (NSArray *)titArr{
    if(_titArr==nil){
        _titArr=[NSMutableArray arrayWithObjects:@"基本资料",@"附件信息",nil];
    }
    return _titArr;
}

- (ProcessModel *)model {
    if (_pModel == nil) {
        _pModel = [[ProcessModel alloc] init];
    }
    return _pModel;
}

- (ProcessRecordModel *)currentRecordModel {
    if (_currentRecordModel == nil) {
        _currentRecordModel = [[ProcessRecordModel alloc] init];
    }
    return _currentRecordModel;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    // 获取数据
    if (self.processID) {
        //最新数据
        self.processRecoedArray = [self getProgessRecordModelArrayWithID:self.processID];
        self.currentRecordModel = self.processRecoedArray[0];
    }
    if(self.currentRecordModel.ID==nil)
    {
        [LSUtility showToastWithMessage:@"数据获取异常。" inView:self.view Andtime:1.8];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.navigationController popViewControllerAnimated:YES];
        });
        return;
    }
    
    // 流程类型
    if (self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE) {
        self.title = @"督办单";
    } else if (self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_FOLLOW) {
        self.title = @"跟进单";
    }
    
    // 监理跟进(待复查)
    if (self.gengjing && self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK &&self.jianLiDaiFuCha==YES)
    {
        [self createView];
    }else if (self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK&&self.currentRecordModel.SEND_TYPE==4&&self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE){
        NSLog(@"监理待复查，发送形式为无，督办");
         [self createView];
    }
    // 待办督办单
    else if (self.daiBDetail && self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE){
        self.edit = (self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_DOING || self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_START || self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK_PASS_YES_NO || self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_REVIEW_PASS_YES);
        
    }
    // 待办跟进单
    else if (self.daiBDetail && self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_FOLLOW) {
        
        self.edit = (self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_DOING || self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK_PASS_YES_NO || self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_REVIEW_PASS_YES);

    }
    
    if (self.edit) {
       self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"wancheng"] style:UIBarButtonItemStyleDone target:self action:@selector(show)];
    }
    [self createsliderBtn];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveData:) name:@"succeedSGFDaiBan" object:nil];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"succeedSGFDaiBan" object:nil];
    
}
#pragma mark--创建视图

- (void)createsliderBtn{
    SegmentViewController *vc = [[SegmentViewController alloc]init];
    vc.height = DEF_SCREEN_HEIGHT - 108;

    // 名称数组
    NSMutableArray *mTitleArr = [NSMutableArray array];
    // 子视图数组
    NSMutableArray *controlArray = [NSMutableArray array];
    // 基本信息
    BasicInformationViewController *a_gjCtr=[[BasicInformationViewController alloc]init];
    a_gjCtr.edit = self.edit;
    a_gjCtr.prModel = [self.processRecoedArray firstObject];;
    a_gjCtr.addressInfo = self.addressInfo;
    a_gjCtr.endTime = self.endTime;
    a_gjCtr.beginTime = self.beginTime;
    [mTitleArr addObject:@"基本资料"];
    [mTitleArr addObject:@"附件信息"];

    [controlArray addObject:a_gjCtr];
    GLDBViewController_Detail_B *b_gjCtr=[[GLDBViewController_Detail_B alloc]init];
    b_gjCtr.processRecoedArray = self.processRecoedArray;
    b_gjCtr.isEdit =  self.edit;
    if (self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE) {
        b_gjCtr.duban = YES;
    }else if (self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_FOLLOW ){
        b_gjCtr.genjin = YES;
    }
    
    [controlArray addObject:b_gjCtr];
    
    // 流转信息
    JLLiuZhuanViewController *jllzCtr=[[JLLiuZhuanViewController alloc]init];
    jllzCtr.processModel = self.pModel;
    jllzCtr.pID = self.pModel.ID;
    jllzCtr.processRecordArray = self.processRecoedArray;
    //设置选中字体颜色
    vc.titleSelectedColor = [UIColor colorWithRed:0.15 green:0.58 blue:0.56 alpha:1.00];
   
    if ([self.flag isEqualToString:@"detail"]) {
        [mTitleArr addObject:@"流转信息"];
        [controlArray addObject:jllzCtr];
    }
    //添加标题
    vc.titleArray = mTitleArr;
    //设置子视图
    vc.subViewControllers = controlArray;
    //设置选中字体颜色
    vc.titleSelectedColor = [TTTheme defaultManger].defaultColor;
    //标签栏背景色
    vc.headViewBackgroundColor=[UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1.00];
    //非选中状态下标签字体大小
    vc.fontSize=14.;
    //选中下划线颜色
    vc.bottomLineColor=[TTTheme defaultManger].defaultColor;
    vc.buttonWidth = DEF_SCREEN_WIDTH / controlArray.count;
    vc.buttonHeight = 44;
    [vc initSegment];
    [vc addParentController:self];
}



- (void)createView {
    UIButton *btn_1=[[UIButton alloc]initWithFrame:CGRECTS(0, 0, 40, 20)];
    btn_1.backgroundColor=[UIColor whiteColor];
    [btn_1 setTitle:@"合格" forState:UIControlStateNormal];
    btn_1.layer.cornerRadius=3.;
    btn_1.tag=100;
    btn_1.titleLabel.font=[UIFont systemFontOfSize:11.];
    [btn_1 setTitleColor:[UIColor colorWithRed:0.29 green:0.68 blue:0.64 alpha:1.00] forState:UIControlStateNormal];
    [btn_1 addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *btn_2=[[UIButton alloc]initWithFrame:CGRECTS(0, 0, 40, 20)];
    btn_2.tag=101;
    btn_2.backgroundColor=[UIColor whiteColor];
    btn_2.titleLabel.font=[UIFont systemFontOfSize:11.];
    btn_2.layer.cornerRadius=3.;
    [btn_2 setTitle:@"不合格" forState:UIControlStateNormal];
    [btn_2 setTitleColor:[UIColor colorWithRed:0.75 green:0.19 blue:0.23 alpha:1.00] forState:UIControlStateNormal];
    [btn_2 addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *bar_Btn_1=[[UIBarButtonItem alloc]initWithCustomView:btn_1];
    UIBarButtonItem *bar_Btn_2=[[UIBarButtonItem alloc]initWithCustomView:btn_2];
    self.navigationItem.rightBarButtonItems=@[bar_Btn_2,bar_Btn_1];
}

#pragma mark -methlod
- (void)show {
    [self showAlert];
}

- (void)clickAction:(UIButton *)sender{
    if(sender.tag==100){
        //合格
        _qualified = PROCESS_STAGE_CHECK_PASS_YES;
        
        [self showAlert];
        
    }else if(sender.tag==101){
        //不合格
        _qualified = PROCESS_STAGE_DOING;
        //督办为无 仍为待复查
        if(self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK&&self.currentRecordModel.SEND_TYPE==4&&self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE){
            _qualified = PROCESS_STAGE_CHECK;
        }
        [self showAlert];
        
    } else if (sender.tag==102) {
        
        if (self.content && ![self.content isEqualToString:@""]) {
            // 施工方待办详情(待执行)
            if (self.daiBDetail) { 
                _qualified = PROCESS_STAGE_CHECK;
            }
            //提交
            [alert hide];
            [self reView];
            
        } else {
            [LSUtility showToastWithMessage:@"请输入说明" inView:self.navigationController.view Andtime:1.];
        }
        
    } else{
        //关闭审阅
        [alert hide];
    }
}



- (void)showAlert{
    
    alert = [[FDAlertView alloc] init];
    AlertVIew *contentView=[[AlertVIew alloc]initWithFrame:CGRECTS(0, 0, 300, 200)];
    if (self.daiBDetail) {
        contentView.title.text = @"说明";
    } else if (self.gengjing && self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK) {
        contentView.title.text = @"复查意见";
    }
    
    contentView.textViewBlock=^(NSString *value){
        self.content = value;
    };
    
    //提交btn
    UIButton *submitBtn= contentView.submit;
    submitBtn.tag=102;
    [submitBtn addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //关闭btn
    UIButton *closeBtn= contentView.closeBtn;
    closeBtn.tag=103;
    [closeBtn addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //添加到alert
    alert.contentView = contentView;
    [alert show:self.view];
}

#pragma mark- 审阅
- (void)reView {
    // 待办
    if (self.daiBDetail||(self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK&&self.currentRecordModel.SEND_TYPE==4&&self.currentRecordModel.PROCESS_TYPE == PROCESS_TYPE_SUPERVISE)) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"updateAttachment" object:nil];
    } else {    // 监理跟进(待复查)
        [self saveData:nil];
    }
}

- (void)saveData:(NSNotification *)text{
    
    if (text) {
        NSDictionary *imageDic = text.userInfo;
        // 流程记录ID
        self.flowRecordID = imageDic[@"ID"];
        // 附件信息
        self.fileinfos = imageDic[@"ARRAY"];
    } else {
        // 流程记录ID
        self.flowRecordID = [NSUUID UUID].UUIDString;
        // 附件信息
        self.fileinfos = self.currentRecordModel.FILEINFOS;
    }
    
    //新增页面
    [self changeFlow];
    [self addFlowRecordData];
    
    //编辑页面
    
    if (self.daiBDetail) {
        // 待办列表页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"sgfDaiB" object:nil];
        // 监理跟进列表页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"jlGenJin" object:nil];
        // 监理督办列表页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"jianLiDuBan" object:nil];
        // 通知首页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"home" object:nil];
    } else if(self.gengjing) {
        // 监理跟进列表页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"jlGenJin" object:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"jianLiDuBan" object:nil];

        // 通知首页刷新数据
        [[NSNotificationCenter defaultCenter] postNotificationName:@"home" object:nil];
    }
    [self.navigationController popViewControllerAnimated:YES];
}

//修改流程状态表
- (void)changeFlow {
    FMDatabase *db = [FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    [db open];
    // 修改流程
    NSString *sqlStr2;
    if (self.daiBDetail)
    {
        sqlStr2 = [NSString stringWithFormat:@"UPDATE PROCESS SET PROCESS_STAGE = '%d', LOCAL_MODIFY_STATE = 'MOD', MODIFY_USER_NAME = '%@', MODIFY_IP = '%@', MODIFY_TIME = '%@' WHERE ID = '%@'", _qualified, DEF_PERSISTENT_GET_OBJECT(@"realname"), [LSUtility getIPAddress], [LSUtility nowTime], self.currentRecordModel.PROCESS_ID];
    } else if (self.gengjing && self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK && _qualified != 5) {
        sqlStr2 = [NSString stringWithFormat:@"UPDATE PROCESS SET PROCESS_STAGE = '%d', LOCAL_MODIFY_STATE = 'MOD', RECIFY_REVIEW_USERS = '%@', MODIFY_USER_NAME = '%@', MODIFY_IP = '%@', MODIFY_TIME = '%@' WHERE ID = '%@'", _qualified, USERID, DEF_PERSISTENT_GET_OBJECT(@"realname"), [LSUtility getIPAddress], [LSUtility nowTime], self.currentRecordModel.PROCESS_ID];
    } else if (self.gengjing && self.currentRecordModel.PROCESS_STAGE == PROCESS_STAGE_CHECK && _qualified == 5) {
        sqlStr2 = [NSString stringWithFormat:@"UPDATE PROCESS SET END_TIME = '%@', PROCESS_STAGE = '%d', LOCAL_MODIFY_STATE = 'MOD', RECIFY_REVIEW_USERS = '%@', MODIFY_USER_NAME = '%@', MODIFY_IP = '%@', MODIFY_TIME = '%@' WHERE ID = '%@'", [LSUtility nowTime], _qualified, USERID, DEF_PERSISTENT_GET_OBJECT(@"realname"), [LSUtility getIPAddress], [LSUtility nowTime], self.currentRecordModel.PROCESS_ID];
    }
    if([db executeUpdate:sqlStr2]){
        NSLog(@"修改成功");
    }else{
        NSLog(@"修改失败");
    }
    [db close];
}

#pragma mark - 新增数据(流程记录表)
- (void)addFlowRecordData {
    FMDatabase *db=[FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    [db open];
    DBHelper *dbhelper=[DBHelper help];
    // 流程ID
    NSString *ID;
    if (self.processID) {
        ID = self.processID;
    } else {
        ID = self.pModel.ID;
    }
    // 意见
    NSString *opinionStr;
    // 说明
    NSString *descStr;
    // 审阅人
    NSString *reviewUser;
    if (self.gengjing) {
        opinionStr = DEFISNUL(self.content);
        descStr = DEFISNUL(self.currentRecordModel.PROCESS_DESC);
        reviewUser = USERID;
    } if (self.daiBDetail) {
        //        opinionStr = DEFISNUL(self.currentRecordModel.REVIEW_OPINION);
        //        descStr = DEFISNUL(self.content);
        //三期更改此处 施工方待办没有说明意见 只有说明
        //        opinionStr = DEFISNUL(self.content);
        //        descStr = DEFISNUL(self.currentRecordModel.PROCESS_DESC);
        opinionStr = @"";
        descStr = DEFISNUL(self.content);
        
        reviewUser = self.currentRecordModel.REVIEW_USER;
    }
    //字段及对应值
    NSDictionary *pragameDic=[NSDictionary dictionary];
    pragameDic=@{
                 @"ID":self.flowRecordID,
                 @"PRO_ID":DEFISNUL(self.currentRecordModel.PRO_ID),
                 @"PROCESS_ID":DEFISNUL(self.currentRecordModel.PROCESS_ID),
                 @"WEATHER":DEFISNUL(self.currentRecordModel.WEATHER),
                 @"ADDRESS_ID":DEFISNUL(self.currentRecordModel.ADDRESS_ID),
                 @"ADDRES_INFO":DEFISNUL(self.currentRecordModel.ADDRES_INFO),
                 @"PROCESS_TYPE":[NSString stringWithFormat:@"%ld", (long)self.currentRecordModel.PROCESS_TYPE],
                 @"PROCESS_STAGE":[NSString stringWithFormat:@"%d", _qualified],
                 @"RECORD_USER":USERID,
                 @"PROBLEM_TYPE":[NSString stringWithFormat:@"%ld", (long)self.currentRecordModel.PROBLEM_TYPE],
                 @"RECORD_MASTER":DEFISNUL(self.currentRecordModel.RECORD_MASTER),
                 @"RECIFY_USER":DEFISNUL(self.currentRecordModel.RECIFY_USER),
                 @"RECIFY_UNIT":DEFISNUL(self.currentRecordModel.RECIFY_UNIT),
                 @"SEVERITY":DEFISNUL(self.currentRecordModel.SEVERITY),
                 @"END_TIME":DEFISNUL(self.currentRecordModel.END_TIME),
                 @"SEND_TIME":[LSUtility nowTime],
                 @"SEND_TYPE":[NSString stringWithFormat:@"%ld", (long)self.currentRecordModel.SEND_TYPE],
                 @"PROCESS_TITLE":DEFISNUL(self.currentRecordModel.PROCESS_TITLE),
                 @"PROCESS_CONTENT":DEFISNUL(self.currentRecordModel.PROCESS_CONTENT),
                 @"PROCESS_REQUIRED":DEFISNUL(self.currentRecordModel.PROCESS_REQUIRED),
                 @"PROCESS_DESC":DEFISNUL(descStr),
                 @"SUBMITTORS":DEFISNUL(self.currentRecordModel.SUBMITTORS),
                 @"PUT_USER":DEFISNUL(self.currentRecordModel.PUT_USER),
                 @"REVIEW_USER":DEFISNUL(reviewUser),
                 @"REVIEW_OPINION":DEFISNUL(opinionStr),
                 @"REVIEW_STATE":[NSString stringWithFormat:@"%ld", (long)self.currentRecordModel.REVIEW_STATE],
                 @"FILEINFOS":DEFISNUL(self.fileinfos),
                 @"EXTEND_INFO":DEFISNUL(self.currentRecordModel.EXTEND_INFO),
                 @"CREATE_USER_NAME":USERID,
                 @"CREATE_TIME":[LSUtility nowTime],
                 @"CREATE_IP":[LSUtility getIPAddress],
                 @"MODIFY_USER_NAME":USERID,
                 @"MODIFY_IP":[LSUtility getIPAddress],
                 @"MODIFY_TIME":[LSUtility nowTime],
                 @"LOCAL_MODIFY_USER_NAME":DEF_PERSISTENT_GET_OBJECT(@"realname"),
                 @"LOCAL_MODIFY_TIME":[LSUtility nowTime],
                 @"LOCAL_MODIFY_STATE":@"ADD",
                 };
    BOOL isAdd=[dbhelper DataBase:db insertKeyValues:pragameDic intoTable:PROCESS_RECORD];
    if(isAdd){
        NSLog(@"验收记录新增成功");
    }else{
        NSLog(@"验收记录新增失败");
    }
    [db close];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//获取流程记录
- (NSMutableArray *)getProgessRecordModelArrayWithID:(NSString *)ID{
    FMDatabase *db = [FMDatabase databaseWithPath:DEF_DB_DATABASEPATH];
    [db open];
    NSString *sql = [NSString stringWithFormat:@"SELECT *, time(CREATE_TIME), date(CREATE_TIME) FROM PROCESS_RECORD WHERE PROCESS_ID = '%@' ORDER BY CREATE_TIME DESC", ID];
    FMResultSet *result = [db executeQuery:sql];
    NSMutableArray *processRecordArray = [NSMutableArray array];

    while ([result next]) {
        ProcessRecordModel *prModel = [[ProcessRecordModel alloc] init];
        prModel.ID= [result stringForColumn:@"ID"];
        prModel.PRO_ID = [result stringForColumn:@"PRO_ID"];
        prModel.PROCESS_ID = [result stringForColumn:@"PROCESS_ID"];
        prModel.ADDRESS_ID = [result stringForColumn:@"ADDRESS_ID"];
        prModel.ADDRES_INFO = [result stringForColumn:@"ADDRES_INFO"];
        prModel.PROCESS_TYPE = [result intForColumn:@"PROCESS_TYPE"];
        prModel.PROCESS_STAGE = [result intForColumn:@"PROCESS_STAGE"];
        prModel.RECORD_USER = [result stringForColumn:@"RECORD_USER"];
        prModel.PROBLEM_TYPE = [result intForColumn:@"PROBLEM_TYPE"];
        prModel.RECORD_MASTER = [result stringForColumn:@"RECORD_MASTER"];
        prModel.RECIFY_USER = [result stringForColumn:@"RECIFY_USER"];
        prModel.RECIFY_UNIT = [result stringForColumn:@"RECIFY_UNIT"];
        prModel.SEVERITY = [result stringForColumn:@"SEVERITY"];
        prModel.END_TIME = [result stringForColumn:@"END_TIME"];
        prModel.SEND_TIME = [result stringForColumn:@"SEND_TIME"];
        prModel.SEND_TYPE = [result intForColumn:@"SEND_TYPE"];
        prModel.PROCESS_TITLE = [result stringForColumn:@"PROCESS_TITLE"];
        prModel.PROCESS_CONTENT = [result stringForColumn:@"PROCESS_CONTENT"];
        prModel.PROCESS_REQUIRED = [result stringForColumn:@"PROCESS_REQUIRED"];
        prModel.PROCESS_DESC = [result stringForColumn:@"PROCESS_DESC"];
        prModel.SUBMITTORS = [result stringForColumn:@"SUBMITTORS"];
        prModel.PUT_USER = [result stringForColumn:@"PUT_USER"];
        prModel.REVIEW_OPINION = [result stringForColumn:@"REVIEW_OPINION"];
        prModel.FILEINFOS = [result stringForColumn:@"FILEINFOS"];
        prModel.EXTEND_INFO = [result stringForColumn:@"EXTEND_INFO"];
        prModel.CREATE_USER_NAME = [result stringForColumn:@"CREATE_USER_NAME"];
        prModel.CREATE_TIME = [result stringForColumn:@"CREATE_TIME"];
        prModel.CREATE_DATE = [result stringForColumn:@"date(CREATE_TIME)"];
        prModel.SUBCREATE_TIME = [result stringForColumn:@"time(CREATE_TIME)"];
        prModel.zhuangtai = [result intForColumn:@"REVIEW_STATE"];
        prModel.REVIEW_USER = [result stringForColumn:@"REVIEW_USER"];
        //本地状态 用于判断能否编辑
        prModel.LOCAL_MODIFY_STATE = [result stringForColumn:@"LOCAL_MODIFY_STATE"];
        [processRecordArray addObject:prModel];
    }
    [db close];
    return processRecordArray;
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end



